<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
</head>
<body>
<script type="text/javascript">
//冒泡排序
/*
var arr=[32,13,43,1,3,44,51,6];
arr.sort(function(a,b){
	return a-b;
})
console.log(arr);
*/

//换位置
/*
var arr=[32,13];
var num=arr[0];
arr[0]=arr[1];
arr[1]=num;
console.log(arr);
*/


var arr=[32,13,43,1,3,44,51,6];
var len=arr.length;
for(var i=0;i<len;i++){
	for(var j=i+1;j<len;j++){
		if(arr[i]>arr[j]){
			var num=arr[i];
			arr[i]=arr[j];
			arr[j]=num;
		}
		
	}
}
console.log(arr);
</script>
</body>
</html>